import time
import threading

# 长时间运行的任务
def long_running_task(callback):
    print("Task started")
    time.sleep(3)  # 模拟耗时操作
    result = 42
    print("Task completed")
    callback(result)  # 调用回调函数

# 回调函数
def callback_function(result):
    print(f"Callback executed with result: {result}")

if __name__ == '__main__':
    # 使用线程执行任务
    thread = threading.Thread(target=long_running_task, args=(callback_function,))
    thread.start()
    thread.join()  # 等待线程完成